#include "mainwindow.h"

void TemDataThread::run()
{
    sensor_data_node_cpp = rclcpp::Node::make_shared("sensor_data_node");
    // 订阅
    tem_lis = sensor_data_node_cpp->create_subscription<std_msgs::msg::Int32>(
        "tem_talker",10,std::bind(&TemDataThread::tem_data_cb, this, std::placeholders::_1));
    thickness_lis = sensor_data_node_cpp->create_subscription<std_msgs::msg::Int32>(
        "thickness_talker",10,std::bind(&TemDataThread::thickness_data_cb,this,std::placeholders::_1));
    roughness_lis =sensor_data_node_cpp->create_subscription<std_msgs::msg::Int32>(
        "roughness_talker",10,std::bind(&TemDataThread::roughness_data_cb,this,std::placeholders::_1));
    // spin阻塞
    rclcpp::spin(sensor_data_node_cpp);
}

// 温度传感器
void TemDataThread::tem_data_cb(const std_msgs::msg::Int32 tem_msg)
{
    int data = tem_msg.data;
    tem_emit(data);
}
// 漆膜仪
void TemDataThread::thickness_data_cb(const std_msgs::msg::Int32 thickness_msg)
{
    int data = thickness_msg.data;
    thickness_emit(data);
}
// 粗糙度
void TemDataThread::roughness_data_cb(const std_msgs::msg::Int32 roughness_msg)
{
    int data = roughness_msg.data;
    roughness_emit(data);
}

